package com.vitabuybuy.tv.ui.home.group.adapter

import android.text.Html
import androidx.recyclerview.widget.RecyclerView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemGroupMemberBinding
import com.vitabuybuy.tv.dto.GroupBuyMemberDto
import com.library.common.base.BindRecycAdapter

class MemberListAdapter : BindRecycAdapter<ItemGroupMemberBinding, GroupBuyMemberDto>() {
    override fun onBindViewHolder(
        mBinding: ItemGroupMemberBinding,
        itemData: GroupBuyMemberDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.itemData = itemData
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
            mBinding.tvShortOfSuccess1.text = Html.fromHtml(
                String.format(mContext.getString(R.string.short_of_success), (itemData.memberLimit - itemData.memberQuantity)),
                Html.FROM_HTML_MODE_COMPACT
            )
        }
    }

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_group_member
    }
}
